﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Windows.Forms;

namespace lx
{
        /// <summary>
        /// 只显示下边框的TextBox控件
        /// </summary>
        public class MyBottomTextBox : TextBox
        {
            public MyBottomTextBox()
            {
                this.BorderStyle = BorderStyle.None;
                this.BackColor = SystemColors.Control;
            }

 
        private int WM_PAINT = 0x000F;
        protected override void WndProc(ref Message m)
        {
            base.WndProc(ref m);
 
            if (m.Msg == WM_PAINT)
            {
                Pen pen = new Pen(Brushes.Olive, 1.5f);
                using (Graphics g = this.CreateGraphics())
                {
                    g.DrawLine(pen, new Point(0, this.Size.Height - 1), new Point(this.Size.Width, this.Size.Height - 1));
                }
            }
        }

        [DllImport("kernel32.dll", CharSet = CharSet.Auto)]
        static extern IntPtr LoadLibrary(string lpFileName);

        protected override CreateParams CreateParams
        {
            get
            {
                CreateParams prams = base.CreateParams;
                if (LoadLibrary("msftedit.dll") != IntPtr.Zero)
                {
                    prams.ExStyle |= 0x020;
                    prams.ClassName = "RICHEDIT50W";
                }
                return prams;
            }
        }

    }

        class MyButton : System.Windows.Forms.Button //继承之系统按钮控件
        {

            protected override void OnPaint(PaintEventArgs e)
            {//重写
                base.OnPaint(e);
                System.Drawing.Pen pen = new Pen(this.BackColor, 3);
                e.Graphics.DrawRectangle(pen, 0, 0, this.Width, this.Height);//填充

                pen.Dispose();

            }
        }
}
